package com.xhlj.controller;

import com.xhlj.service.ConferenceService;
import com.xhlj.utils.Result;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Objects;

@RestController
@RequestMapping("conference")
public class ConferenceController {
    @Resource
    private ConferenceService conferenceService;

    @GetMapping
    public Result getConferenceList() {
        Result result = conferenceService.getConferenceList();
        return result;
    }

    //TODO:根据日期获取会议信息
    @GetMapping("list")
    public Result getConferenceMsgByDate(@RequestParam(defaultValue = "") String dateString) throws ParseException {
        if(Objects.equals(dateString, "")) return getConferenceList();
        //String转Date
        Date date = new SimpleDateFormat("yyyy-MM-dd").parse(dateString);
        return conferenceService.getConferenceMsgByDate(date);
    }
}
